<template>
  <div class="app-container">

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <router-link :to="'/mer/restaurant'" class="link-type">
          <el-button icon="el-icon-back" size="mini">
            返 回
          </el-button>
        </router-link>
      </el-col>
      <el-col :span="1.5">
        <el-button type="warning" icon="el-icon-download" size="mini" :loading="exportLoading" @click="handleExport">导出酒水数量</el-button>
      </el-col>
    </el-row>

    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="90px">
      <el-form-item label="查询时间" prop="propertyName">
        <el-date-picker v-model="dateRange" size="mini" style="width: 240px" value-format="yyyy-MM-dd" type="daterange"
                        range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"/>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <div v-for="type in allData" class="product-charts">
      <div>{{type.typeName}}</div>
      <Products :productNames="type.productNames" :saleCounts="type.saleCounts" />
    </div>
<!--    <div class="product-charts">-->
<!--      <Products :productNames="allData[0].productNames" :saleCounts="allData[0].saleCounts" />-->
<!--    </div>-->

  </div>
</template>

<script>
import {beverageExport, exportOrder, productEchart,} from "@/api/module/product/order";

export default {
  name: "Property",
  components: {
    Products: () => import('@/views/module/dataview/Echarts/products'),
  },
  data() {
    return {
      // 按钮loading
      buttonLoading: false,
      // 遮罩层
      loading: true,
      // 导出遮罩层
      exportLoading: false,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      dateRange:[],
      // 总条数
      total: 0,
      // 物业公司表格数据
      productList: [],
      saleCounts:[],
      allData:[],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        merId:undefined,
        beginDate:undefined,
        endDate:undefined
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.queryParams.merId = this.$route.query.merId ? this.$route.query.merId:0;

  },
  mounted() {
    this.getProductList();
  },
  methods: {
    /** 查询物业公司列表 */
    getProductList() {
      this.loading = true;
      productEchart(this.queryParams).then(response => {
        console.log('productEchart',response.data)
        // this.productList = response.data.productNames;
        // this.saleCounts = response.data.saleCounts;
        this.allData = response.data;
      });
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id);
      this.single = selection.length!==1;
      this.multiple = !selection.length
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      console.log('dateRange',this.dateRange);
      if(this.dateRange !=undefined && this.dateRange.length === 2){
        this.queryParams.beginDate = this.dateRange[0];
        this.queryParams.endDate = this.dateRange[1];
      }
      this.getProductList();
    },
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm('是否确认导出所有酒水数据项?', "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(() => {
        this.exportLoading = true;
        return beverageExport(queryParams);
      }).then(response => {
        this.download(response.msg);
        this.exportLoading = false;
      }).catch(() => {});
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    orderDetail(row){

    }
  }
};
</script>

<style rel="stylesheet/scss" lang="scss" scoped>


  .product-charts{
    position: relative;
    width: 100%;
    height: 500px;
  }

  .panel-group {
    margin-top: 10px;
    .card-panel-col{
      margin-bottom: 10px;
    }
    .card-panel {
      height: 108px;
      font-size: 12px;
      position: relative;
      overflow: hidden;
      cursor: pointer;
      color: #666;
      background: #fff;
      box-shadow: 4px 4px 40px rgba(0, 0, 0, .05);
      border-color: rgba(0, 0, 0, .05);



      .icon-people {
        color: #40c9c6;
      }
      .icon-message {
        color: #36a3f7;
      }
      .icon-money {
        color: #f4516c;
      }
      .icon-shopping {
        color: #34bfa3
      }
      .card-panel-icon-wrapper {
        float: left;
        margin: 14px 0 0 14px;
        padding: 16px;
        transition: all 0.38s ease-out;
        border-radius: 6px;
      }
      .card-panel-icon {
        float: left;
        font-size: 48px;
      }
      .card-panel-description {
        float: right;
        font-weight: bold;
        margin: 26px;
        color:white;
        /*margin-left: 0px;*/
        .card-panel-text {
          line-height: 18px;
          color: rgba(0, 0, 0, 0.45);
          font-size: 16px;
          margin-bottom: 12px;
        }
        .card-panel-num {
          font-size: 20px;
        }
      }
    }
  }
</style>
